package com.swufe.lianxi;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ConfigActivity2 extends AppCompatActivity {

    private static final String TAG = "Rate";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config2);

        Intent config=getIntent();
        float dollar2=config.getFloatExtra("dollar_key",0.0f);
        float euro2=config.getFloatExtra("euro_key",0.0f);
        float won2=config.getFloatExtra("won_key",0.0f);

        EditText dollar = findViewById(R.id.edit1);
        EditText euro = findViewById(R.id.edit2);
        EditText won = findViewById(R.id.edit3);
        dollar.setText(""+dollar2);
        euro.setText(""+euro2);
        won.setText(""+won2);

        Log.i(TAG,"onCreate:dollar:"+dollar2);
        Log.i(TAG,"onCreate:euro:"+euro2);
        Log.i(TAG,"onCreate:won:"+won2);
    }

    public void open(View v){
        Log.i(TAG,"open:");
        EditText dollar = findViewById(R.id.edit1);
        EditText euro = findViewById(R.id.edit2);
        EditText won = findViewById(R.id.edit3);

        //Intent Rate=new Intent(this,RateActivity.class);
        String str1 = dollar.getText().toString();
        String str2 = euro.getText().toString();
        String str3 = won.getText().toString();

        float r1 = Float.parseFloat(str1);
        float r2 = Float.parseFloat(str2);
        float r3= Float.parseFloat(str3);

        //Rate.putExtra("dollar_key1",r1);
        //Rate.putExtra("euro_key1",r2);
        //Rate.putExtra("won_key1",r3);

        Log.i(TAG,"获取到新的汇率");
        Log.i(TAG,"open:dollarRate="+r1);
        Log.i(TAG,"open:euroRate="+r2);
        Log.i(TAG,"open:wonRate="+r3);
        //startActivity(Rate);
        Intent intent=getIntent();
        Bundle bdl=new Bundle();
        bdl.putFloat("dollar_key",r1);
        bdl.putFloat("euro_key",r2);
        bdl.putFloat("won_key",r3);
        intent.putExtras(bdl);
        setResult(2,intent);
        finish();
    }

    }

